package com.shenzhen.horselive.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.shenzhen.horselive.R;
import com.shenzhen.horselive.common.utils.handler.IFilterHandler;
import com.shenzhen.horselive.databinding.DialogLoginBinding;
import com.shenzhen.horselive.databinding.DialogOneButtonBinding;

public class CommentOneButtonDialog extends Dialog {


    private OneButtonClickListener   listener;

    public void setListener(OneButtonClickListener listener) {
        this.listener = listener;
    }

    public CommentOneButtonDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public CommentOneButtonDialog(Context context, int theme) {
        super(context, theme);
    }


    DialogOneButtonBinding   binding;
    public CommentOneButtonDialog(Context context) {
        super(context, R.style.CommonDialog);
        //初始化
        binding = DialogOneButtonBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        binding.btGo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener!=null)
                {
                    listener.OnClick();
                }
            }
        });

    }

    @Override
    public void show() {
        super.show();
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.width= ViewGroup.LayoutParams.MATCH_PARENT;
        layoutParams.height= ViewGroup.LayoutParams.WRAP_CONTENT;
        layoutParams.gravity = Gravity.CENTER;
        getWindow().setAttributes(layoutParams);
    }

    //titile
public  void  setTitleText(String  title)
{
    binding.tvText.setText(title);
}
//内容
    public  void  setContent(String  content)
    {
        binding.tvContent.setText(content);
    }

    //确认
    public void setConfirm(View.OnClickListener onClickListener) {
        binding.btGo.setOnClickListener(onClickListener);
    }






    public   interface   OneButtonClickListener{
        void   OnClick();
    }


}
